<script>
    //使用#号实现私有成员
    class Shape{
        #width;  //私有成员
        get width(){
            return this.#width;
        }
        set width(value){
            if(value>0){
                this.#width=value;
            }
            else{
                throw "宽度只能大于0";
            }
        }
    }

    let s1=new Shape();
    s1.width=100;
    //Private field '#width' must be declared in an enclosing class
    //console.log(s1.#width);
    console.log(s1.width);
    s1.width=-100;
</script>